package segment

import "encoding/json"

type Text struct {
	Text string `json:"text"`
	Pos  Pos    `json:"pos"`
}

func NewText(text string, posCode string) Text {
	return Text{Text: text, Pos: POS[posCode]}
}

func (t *Text) Marshal() ([]byte, error) {
	return json.Marshal(t)
}

func (t *Text) Unmarshal(data []byte) error {
	return json.Unmarshal(data, t)
}

func (t *Text) String() string {
	j, _ := t.Marshal()
	return string(j)
}
